<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="root"></div>
  <div id="root1"></div>
  <div id="root2"></div>
  <script src="../js/react.development.js"></script>
  <script src="../js/react-dom.development.js"></script>
  <script src="../js/babel.min.js"></script>
  <script type="text/babel">
    class MyComponent extends React.Component {
      render() {
        // 使用 props
        const { name, age, sex } = this.props
        return (
          <ul>
            <li>姓名：{name}</li>
            <li>年龄：{age+1}</li>
            <li>性别：{sex}</li>
          </ul>
        )
      }
    }
    // 传递props，
    // 第一种方式：直接传递
    ReactDOM.render(<MyComponent name="tom" age="18" sex="男" />, document.getElementById('root'))

    // 第二种方式：批量传递
    const person = { name: 'lsh', age: 19, sex: '女' }
    ReactDOM.render(<MyComponent {...person} />, document.getElementById('root1'))
    // 传数值方式需要将值写成表达式
    ReactDOM.render(<MyComponent name="小呆" age={28} sex="男" />, document.getElementById('root2'))
  </script>
</body>
</html>